<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * AUTOLOAD,AUTOLOADPLAN,MANUALLOAD
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Services extends Application_Model_ModelAbstract
{

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_Idservices;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_ApplicationIdapplication;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Description;

    /**
     * Database var type varchar(512)
     *
     * @var string
     */
    protected $_Monmenu;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_IconeClsIdiconeCls;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Orderaff;


    /**
     * Parent relation fk_services_application1
     *
     * @var Application_Model_Application
     */
    protected $_Application;

    /**
     * Parent relation fk_services_iconeCls1
     *
     * @var Application_Model_Iconecls
     */
    protected $_Iconecls;


    /**
     * Dependent relation fk_actionsapplication_services1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Actionsapplication
     */
    protected $_Actionsapplication;

    /**
     * Dependent relation fk_Droit_Service_services1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_DroitService
     */
    protected $_DroitService;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idservices'=>'Idservices',
            'application_idapplication'=>'ApplicationIdapplication',
            'Description'=>'Description',
            'monmenu'=>'Monmenu',
            'iconeCls_idiconeCls'=>'IconeClsIdiconeCls',
            'orderaff'=>'Orderaff',
        ));

        $this->setParentList(array(
            'FkServicesApplication1'=> array(
                    'property' => 'Application',
                    'table_name' => 'Application',
                ),
            'FkServicesIconeCls1'=> array(
                    'property' => 'Iconecls',
                    'table_name' => 'Iconecls',
                ),
        ));

        $this->setDependentList(array(
            'FkActionsapplicationServices1' => array(
                    'property' => 'Actionsapplication',
                    'table_name' => 'Actionsapplication',
                ),
            'FkDroitServiceServices1' => array(
                    'property' => 'DroitService',
                    'table_name' => 'DroitService',
                ),
        ));
    }

    /**
     * Sets column idservices
     *
     * @param string $data
     * @return Application_Model_Services
     */
    public function setIdservices($data)
    {
        $this->_Idservices = $data;
        return $this;
    }

    /**
     * Gets column idservices
     *
     * @return string
     */
    public function getIdservices()
    {
        return $this->_Idservices;
    }

    /**
     * Sets column application_idapplication
     *
     * @param string $data
     * @return Application_Model_Services
     */
    public function setApplicationIdapplication($data)
    {
        $this->_ApplicationIdapplication = $data;
        return $this;
    }

    /**
     * Gets column application_idapplication
     *
     * @return string
     */
    public function getApplicationIdapplication()
    {
        return $this->_ApplicationIdapplication;
    }

    /**
     * Sets column Description
     *
     * @param text $data
     * @return Application_Model_Services
     */
    public function setDescription($data)
    {
        $this->_Description = $data;
        return $this;
    }

    /**
     * Gets column Description
     *
     * @return text
     */
    public function getDescription()
    {
        return $this->_Description;
    }

    /**
     * Sets column monmenu
     *
     * @param string $data
     * @return Application_Model_Services
     */
    public function setMonmenu($data)
    {
        $this->_Monmenu = $data;
        return $this;
    }

    /**
     * Gets column monmenu
     *
     * @return string
     */
    public function getMonmenu()
    {
        return $this->_Monmenu;
    }

    /**
     * Sets column iconeCls_idiconeCls
     *
     * @param string $data
     * @return Application_Model_Services
     */
    public function setIconeClsIdiconeCls($data)
    {
        $this->_IconeClsIdiconeCls = $data;
        return $this;
    }

    /**
     * Gets column iconeCls_idiconeCls
     *
     * @return string
     */
    public function getIconeClsIdiconeCls()
    {
        return $this->_IconeClsIdiconeCls;
    }

    /**
     * Sets column orderaff
     *
     * @param int $data
     * @return Application_Model_Services
     */
    public function setOrderaff($data)
    {
        $this->_Orderaff = $data;
        return $this;
    }

    /**
     * Gets column orderaff
     *
     * @return int
     */
    public function getOrderaff()
    {
        return $this->_Orderaff;
    }

    /**
     * Sets parent relation ApplicationIdapplication
     *
     * @param Application_Model_Application $data
     * @return Application_Model_Services
     */
    public function setApplication(Application_Model_Application $data)
    {
        $this->_Application = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idapplication'];
        }

        $this->setApplicationIdapplication($primary_key);

        return $this;
    }

    /**
     * Gets parent ApplicationIdapplication
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Application
     */
    public function getApplication($load = true)
    {
        if ($this->_Application === null && $load) {
            $this->getMapper()->loadRelated('FkServicesApplication1', $this);
        }

        return $this->_Application;
    }

    /**
     * Sets parent relation IconeClsIdiconeCls
     *
     * @param Application_Model_Iconecls $data
     * @return Application_Model_Services
     */
    public function setIconecls(Application_Model_Iconecls $data)
    {
        $this->_Iconecls = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idiconeCls'];
        }

        $this->setIconeClsIdiconeCls($primary_key);

        return $this;
    }

    /**
     * Gets parent IconeClsIdiconeCls
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Iconecls
     */
    public function getIconecls($load = true)
    {
        if ($this->_Iconecls === null && $load) {
            $this->getMapper()->loadRelated('FkServicesIconeCls1', $this);
        }

        return $this->_Iconecls;
    }

    /**
     * Sets dependent relations fk_actionsapplication_services1
     *
     * @param array $data An array of Application_Model_Actionsapplication
     * @return Application_Model_Services
     */
    public function setActionsapplication(array $data)
    {
        $this->_Actionsapplication = array();

        foreach ($data as $object) {
            $this->addActionsapplication($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_actionsapplication_services1
     *
     * @param Application_Model_Actionsapplication $data
     * @return Application_Model_Services
     */
    public function addActionsapplication(Application_Model_Actionsapplication $data)
    {
        $this->_Actionsapplication[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_actionsapplication_services1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Actionsapplication
     */
    public function getActionsapplication($load = true)
    {
        if ($this->_Actionsapplication === null && $load) {
            $this->getMapper()->loadRelated('FkActionsapplicationServices1', $this);
        }

        return $this->_Actionsapplication;
    }

    /**
     * Sets dependent relations fk_Droit_Service_services1
     *
     * @param array $data An array of Application_Model_DroitService
     * @return Application_Model_Services
     */
    public function setDroitService(array $data)
    {
        $this->_DroitService = array();

        foreach ($data as $object) {
            $this->addDroitService($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_Droit_Service_services1
     *
     * @param Application_Model_DroitService $data
     * @return Application_Model_Services
     */
    public function addDroitService(Application_Model_DroitService $data)
    {
        $this->_DroitService[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_Droit_Service_services1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_DroitService
     */
    public function getDroitService($load = true)
    {
        if ($this->_DroitService === null && $load) {
            $this->getMapper()->loadRelated('FkDroitServiceServices1', $this);
        }

        return $this->_DroitService;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Services
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Services());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Services::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdservices() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idservices = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdservices()));
    }
}
